package com.qijian.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author supo
 */

@Getter
@AllArgsConstructor
public enum YearMonthEnum {

    /**
     * 一月
     */
    JANUARY("01", "januaryAmount"),
    /**
     * 二月
     */
    february("02", "februaryAmount"),
    /**
     * 三月
     */
    MARCH("03", "marchAmount"),
    /**
     * 四月
     */
    APRIL("04", "aprilAmount"),
    /**
     * 五月
     */
    MAY("05", "mayAmount"),
    /**
     * 六月
     */
    JUNE("06", "juneAmount"),
    /**
     * 七月
     */
    JULY("07", "julyAmount"),
    /**
     * 八月
     */
    AUGUST("08", "augustAmount"),
    /**
     * 九月
     */
    SEPTEMBER("09", "septemberAmount"),
    /**
     * 十月
     */
    october("10", "octoberAmount"),
    /**
     * 十一月
     */
    NOVEMBER("11", "novemberAmount"),
    /**
     * 十二月
     */
    December("12", "decemberAmount");

    @EnumValue
    @JsonValue
    private final String month;
    private final String value;


    private static final Map<String, String> ENUM_MAP = new HashMap<>(12);

    static {
        for (YearMonthEnum item : values()) {
            ENUM_MAP.put(item.getMonth(), item.getValue());
        }
    }

    public static String monthToVal(String month) {
        return ENUM_MAP.get(month);
    }
}
